<template>
  <right-template :title="componentData.title" :tabName="componentData.tabName">
    <el-form class="right-icon">
      <slider-normal v-model="commonAttr.fontSize" label="字号" :max="200" :step="1" @change="onChangeAttr"></slider-normal>
      <color-normal v-model="commonAttr.color" label="字体颜色" :format="'rgb'" @change="onChangeAttr"></color-normal>
      <color-normal v-model="commonAttr.backgroundColor" label="背景颜色" format="rgb" @change="onChangeAttr"></color-normal>
      <el-divider content-position="center">字体图标</el-divider>
      <ul class="icons">
        <li v-for="(item, index) in iconLists" :class="item.icon" :key="index" @click.stop="onChangeIcon(index)"></li>
      </ul>
    </el-form>
  </right-template>
</template>

<script>
  import RightTemplate from '@/views/child/right/right-template.vue'
  import ColorNormal from '@/views/components/edit/ColorNormal.vue'
  import SliderNormal from '@/views/components/edit/SliderNormal.vue'

  import { editUtils } from '@/views/js/edit-utils'
  import { SHAPE_TYPES } from '@/common/const-shapes'

  export default {
    name: "RightIcon",
    mixins: [editUtils],
    components: {
      RightTemplate,
      ColorNormal,
      SliderNormal,
    },
    methods: {
      onChangeIcon(index){
        this.updateCurrentComponentData( {commonAttr: { icon: 'jy-icon-' + SHAPE_TYPES[index]}} );
      }
    },
    computed: {
      iconLists(){
        let lists = []
        _.forEach(SHAPE_TYPES, (iconName) => {
          lists.push({ icon: 'jy-icon-' + iconName })
        });
        return lists;
      }
    },
  };
</script>
<style lang="scss">
.icons{
  margin: 10px 20px;
  li{
    display: inline-block;
    font-size: 18px;
    width: 30px;
  }
}
</style>
